<?php
/*
    langito, Content Management System
    Copyright (C) 2007  Leszek Pi�tek <lechup@langito.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

//start session, local variables, ect.
include('includes/init.php');

//autologin
if(!$_SESSION['logged_in'] && $_COOKIE['autologin_'.$conf['session_name']] && $_COOKIE['passwd_'.$conf['session_name']])
	autologin();
//

//including module
if(!$_GET['module'])
	$_GET['module']=$conf['default_module'];
	
if($d=is_module_installed($_GET['module'])) {
	if($d->function==1 || $d->function=='external') include_once('includes/functions/'.$_GET['module'].'.php');
	if($d->module==0 && !$_GET['function'] && !$_POST['function']) { redirect('index.php?module=error&error=module_error'); exit; }
}
else {
	redirect('index.php?module=error&error=module_error');
	exit;
}
//

//starting function from $_GET['function'] variable
if($_GET['function']) {
	$arr=get_defined_functions();
	if(in_array($_GET['function'], $arr['user'])) {
		call_user_func_array($_GET['function'], array());
		exit;
	}
	unset($arr);
}
//

////starting function from $_POST['function'] variable
if($_POST['function']) {
	$arr=get_defined_functions();
	if(in_array($_POST['function'], $arr['user'])) {
		call_user_func_array($_POST['function'], array());
		exit;
	}
	unset($arr);
}
//

//update of redirecting variables $_SESSION[redirect_1], [redirect_2]
redirect_update();

if(!$_GET['module'])
	include('modules/'.$conf['default_module'].'.php');
else
	include('modules/'.$_GET['module'].'.php');

//end index
?>
